﻿using System;
using System.IO;
using Beaker;
using Beaker.Specs;

namespace OpenCube.IO.Specs.Builders
{
	[CLSCompliant(false)]
	public sealed class BigEndianBinaryReaderBuilder
		: Builder<EndiannessAwareBinaryReader>
	{
		private Maybe<Stream> _stream;

		public BigEndianBinaryReaderBuilder FromStream(Stream stream)
		{
			_stream = new Maybe<Stream>(stream);
			return this;
		}

		public override EndiannessAwareBinaryReader Build()
		{
			Stream stream = _stream.GetValueOrDefault(new ByteStreamBuilder().Build());

			return new EndiannessAwareBinaryReader(stream, Endianness.BigEndian);
		}
	}
}